package cn.chenwx.bbsforum.mapper;

import cn.chenwx.bbsforum.entity.Tag;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TagMapper {
    @Insert("insert into tag(tagName) values(#{tagName})")
    void save(Tag tag);

    @Select("select * from tag order by id desc")
    List<Tag> findTagsCloud();

    @Select("select count(*) from tag")
    int countTagsNum();

    @Select("select IFNULL(max(id),0) from tag where tagName = #{tagName}")
    int findIsExistByTagName(@Param("tagName") String tagName);

    @Update("update tag set tagName=#{tagName} where id =#{id}")
    int updateTags(Tag tag);

    @Delete("delete from tag where id=#{id}")
    int deleteTags(@Param("id")int id);
    @Select("select id,tagName from tag")
    List<Tag> findTags();
    @Select("select tagName from tag")
    List<String> findTagName();




}
